<%--
  Created by IntelliJ IDEA.
  User: 28101
  Date: 2021/9/16
  Time: 17:00
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="jstl" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link href="/css/bootstrap-theme.css" rel="stylesheet">
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/animate.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/swiper-bundle.min.css">
    <link rel="stylesheet" href="/css/getPhone.css">
    <script src="/js/jquery-3.3.1.min.js"></script>
    <title>phoneByPid</title>

</head>
<body>

    <div style="height: 50px;background-color: rgba(250, 235, 215, 0.57)">
        <table style="position:relative; left:260px; top:15px;margin-left: 500px">
            <tr>
                <td width="60px" align="center" class="loginbtn">主页</td>
                <td width="200px"></td>

                <td width="200px" align="center" class="shopcartbtn">购物车</td>

                <td width="200px" align="center" class="mycartbtn">我的订单</td>

                <jstl:if test="${user != null}">
                    <div hidden="hidden">${user.uid }</div>
                    <td width="300px" align="center" hidden="hidden">
                            ${user.uid }
                    </td>
                    <td>
                            ${user.name }
                    </td>
                </jstl:if>

                <jstl:if test="${user == null}">
                    <td class="login">
                        登录
                    </td>
                </jstl:if>
            </tr>
        </table>
    </div>

    <div class="lunbodiv">
        <div class="swiper-container">
            <div class="swiper-wrapper">
                <jstl:forEach var="commodityImg" items="${commodity.commodityImgs }">
                    <div class="swiper-slide">
                        <img src="/imgs/${commodityImg.src}" width="80%" height="80%"/>
                    </div>
                </jstl:forEach>
            </div>

            <div class="swiper-scrollbar"></div>
        </div>
    </div>

    <div class="gmdiv">

        <div id="pid" name="${commodity.pid }" hidden="hidden">${commodity.pid }</div>

        <div style="font-size: 30px;" class="phonenamediv">${commodity.commodityName }</div>
        <div class="describetestdiv">${commodity.describetest }</div>
        <div class="textdiv">
            <jstl:forEach var="commodityVersion" items="${commodity.commodityVersion }">
                <jstl:if test="${commodityVersion.vdefault == 1}">
                    <font color="red" size="5" id="cprice"> ${commodityVersion.cprice} 元 </font>
                    <del id="oprice"> ${commodityVersion.oprice}元 </del> <br/>
                </jstl:if>
            </jstl:forEach>
        </div>

        <div class="addrtextdiv">
            <div>收货地址</div>
            <div class="addrdiv">
                ${user.address }<br/>
                ${user.addressList[0].tel }
            </div>
        </div>

        <div>
            <jstl:if test="${commodity.commodityVersion.size() != 0 }">
<%--                <jstl:if test="${commodity.commodityVersion[0].versionname != commodity.commodityName }">--%>
                    <div class="textdiv texttop">
                        选择版本<div name="v0" hidden="hidden" class="cdversion"></div>
                    </div>
                    <div class="tabdiv">
                        <ul>
                            <jstl:forEach var="commodityVersion" items="${commodity.commodityVersion }">
                                <li>
                                    <button class="pvbtn" id="pv${commodityVersion.pvid}" name="${commodityVersion.pvid}">${commodityVersion.versionname}</button>
                                </li>
                            </jstl:forEach>
                        </ul>
                    </div>
<%--                </jstl:if>--%>
            </jstl:if>

            <jstl:if test="${commodity.commodityColors.size() != 0 }">
                <div class="textdiv1 col-md-12">
                    选择颜色<span name="c0" hidden="hidden" class="cdcolor"></span>
                </div>
                <div class="tabdiv">
                    <ul>
                        <jstl:forEach var="commodityColors" items="${commodity.commodityColors }">
                            <li>
                                <button class="pcbtn" id="pc${commodityColors.pcid}" name="${commodityColors.pcid}">${commodityColors.colorname}</button>
                            </li>
                        </jstl:forEach>
                    </ul>
                </div>
            </jstl:if>

        </div>

        <div class="shopdiv col-md-12">
            <button class="shopbtn" id="shop">加入购物车</button>
        </div>

    </div>

    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/swiper-bundle.min.js"></script>
    <script src="/js/getPhone.js"></script>
    <script>

        $("#shop").click(function () {

            var pid = $("#pid").attr("name");
            var pvid = $(".cdversion").attr("name");
            var pcid = $(".cdcolor").attr("name");

            $.get(
                "/ShoppingCartServlet",
                "method=shoppingCart&pid=" + pid + "&pvid=" + pvid + "&pcid=" + pcid,
                function (data) {
                    window.location.href = "jsp/shoppingCustom.jsp";
                },
                "text"
            )

        });

        $(".login").click(function () {
            window.location.href = "jsp/login.jsp";
        });

        $(".loginbtn").click(function () {
            window.location.href = "index.jsp";
        })

        $(".shopcartbtn").click(function () {
            window.location.href = "jsp/shoppingCustom.jsp";
        })

        $(".mycartbtn").click(function () {
            window.location.href = "/HisShoppingCustomServlet?method=getUserHisShoppingCustom";
        })
    </script>

</body>
</html>
